package cn.com.surker.material.dao;

import cn.com.surker.material.entity.MainMaterialHistoryInventory;
import cn.com.surker.material.vo.MaterialHistoryInventoryVo;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 材料历史盘点明细表 Mapper 接口
 * </p>
 *
 * @author admin
 * @since 2024-06-29
 */
public interface MainMaterialHistoryInventoryDao extends BaseMapper<MainMaterialHistoryInventory> {

    /**
     * 分页查询历史盘点明细
     * @param page
     * @param queryWrapper
     * @param <E>
     * @return
     */
    <E extends IPage<MainMaterialHistoryInventory>> E selectFullPage(E page, @Param(Constants.WRAPPER) Wrapper<MainMaterialHistoryInventory> queryWrapper);

    /**
     * 根据仓位ID查询历史盘点记录
     * @param storeId
     * @return
     */
    MainMaterialHistoryInventory findByStoreId(Long storeId);

    /**
     * 查询最后盘点库存
     * @param controlStoreId
     * @param time
     * @return
     */
    MaterialHistoryInventoryVo findByControlMaterial(Long storeId, Long controlStoreId, String time);

    MaterialHistoryInventoryVo findCloudByControlMaterial(String dbCode, Long storeId, Long controlStoreId, String time);
    /**
     * 批量新增
     * @param list
     * @return
     */
    Integer saveBatch(List<MainMaterialHistoryInventory> list);

    /**
     * 查询各仓位最后盘存记录
     * @param orgId
     * @return
     */
    List<MaterialHistoryInventoryVo> findInventoryByOrg(String dbCode, Long orgId, String startTime, String endTime);
}
